﻿#include "RpcServiceManager.h"
#include "XyNet/Common/SetMapHelper.h"
#include "XyNet/Service/RpcService.h"

namespace XyNet
{
	void RpcServiceManager::clear()
	{
		_idServiceMap.clear();
	}

	void RpcServiceManager::addService(shared_ptr<RpcService> service)
	{
		return SetMapHelper::insert(&_idServiceMap, service->getId(), service);
	}

	void RpcServiceManager::removeService(int serviceId)
	{
		return SetMapHelper::erase(&_idServiceMap, serviceId);
	}

	shared_ptr<RpcService> RpcServiceManager::getService(int serviceId)
	{
		auto iterator = _idServiceMap.find(serviceId);
		if (iterator != _idServiceMap.end())
			return iterator->second;
		else
			return nullptr;
	}
}